package com.sjy.web.controller.ship;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sjy.common.annotation.Log;
import com.sjy.common.core.controller.BaseController;
import com.sjy.common.core.domain.AjaxResult;
import com.sjy.common.enums.BusinessType;
import com.sjy.ship.domain.TruckPark;
import com.sjy.ship.service.ITruckParkService;
import com.sjy.common.utils.poi.ExcelUtil;
import com.sjy.common.core.page.TableDataInfo;

/**
 * 当前卡车入园信息Controller
 * 
 * @author lzm
 * @date 2023-06-14
 */
@RestController
@RequestMapping("/park/car")
public class TruckParkController extends BaseController
{
    @Autowired
    private ITruckParkService truckParkService;

    /**
     * 查询当前卡车入园信息列表
     */
    @PreAuthorize("@ss.hasPermi('park:car:list')")
    @GetMapping("/list")
    public TableDataInfo list(TruckPark truckPark)
    {
        startPage();
        List<TruckPark> list = truckParkService.selectTruckParkList(truckPark);
        return getDataTable(list);
    }

    /**
     * 导出当前卡车入园信息列表
     */
    @PreAuthorize("@ss.hasPermi('park:car:export')")
    @Log(title = "当前卡车入园信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TruckPark truckPark)
    {
        List<TruckPark> list = truckParkService.selectTruckParkList(truckPark);
        ExcelUtil<TruckPark> util = new ExcelUtil<TruckPark>(TruckPark.class);
        util.exportExcel(response, list, "当前卡车入园信息数据");
    }

    /**
     * 获取当前卡车入园信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('park:car:query')")
    @GetMapping(value = "/{carBrand}")
    public AjaxResult getInfo(@PathVariable("carBrand") String carBrand)
    {
        return success(truckParkService.selectTruckParkByCarBrand(carBrand));
    }

    /**
     * 新增当前卡车入园信息
     */
    @PreAuthorize("@ss.hasPermi('park:car:add')")
    @Log(title = "当前卡车入园信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody TruckPark truckPark)
    {
        return toAjax(truckParkService.insertTruckPark(truckPark));
    }

    /**
     * 修改当前卡车入园信息
     */
    @PreAuthorize("@ss.hasPermi('park:car:edit')")
    @Log(title = "当前卡车入园信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody TruckPark truckPark)
    {

        return toAjax(truckParkService.updateTruckPark(truckPark));
    }

    /**
     * 删除当前卡车入园信息
     */
    @PreAuthorize("@ss.hasPermi('park:car:remove')")
    @Log(title = "当前卡车入园信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{carBrands}")
    public AjaxResult remove(@PathVariable String[] carBrands)
    {
        return toAjax(truckParkService.deleteTruckParkByCarBrands(carBrands));
    }
}
